package com.hai.prism.driver;

import com.sun.jna.Library;
import com.sun.jna.Pointer;

/**
 * Byte(Char('A'));
 * 
 * @author Hai
 *
 */
public interface CH341 extends Library {
		
	int CH341OpenDevice(long iIndex);
	int CH341CloseDevice(long iIndex);
	
	boolean CH341ReadI2C(long iIndex, byte iDevice, byte iAddr, Pointer oByte);
	boolean CH341WriteI2C(long iIndex, byte iDevice, byte iAddr, byte oByte);
	
	/**
	 * 
	 * @param iIndex
	 * @param iMode  0x82 = 1000 0011
	 * @return
	 * 
	 * 非同步读写不需要设置
	 */
	boolean CH341SetStream(long iIndex, long iMode);
	
	/**
	 * 
	 * @param iIndex  USB.CH341设备序号
	 * @param iWriteLength 包含I2C地址的命令数组长度
	 * @param iWriteBuffer 0必须是I2C地址，后面是命令
	 * @param iReadLength
	 * @param oReadBuffer  传递数据引用即可被回写
	 * @return
	 */
	boolean CH341StreamI2C(long iIndex, long iWriteLength, byte iWriteBuffer[], long iReadLength, byte oReadBuffer[]);
	
}
